// Boost_copy_folder.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <boost/filesystem.hpp>


 

using namespace std;
namespace bf = boost::filesystem;

int g_iHierarchy = 0;

void AppendSpace()
{
	int iHie = g_iHierarchy;

	while( iHie>0 )
	{
		cout<<" ";
		--iHie;
	}
}
void CopyFiles( const bf::path& from, const bf::path& to )
{
	++g_iHierarchy;

	if( !bf::exists(to) )
	{
		bf::create_directories( to );
	}    

	bf::directory_iterator end;

	for( bf::directory_iterator it(from); it != end; ++it )
	{
		bf::path newFrom = from;
		newFrom /= it->filename();

		bf::path newTo = to;
		newTo /= it->filename();

		if( bf::is_directory( newFrom ) )
		{
			AppendSpace();
			cout<<"Copy Directory [" << newFrom.filename() <<"] to ["<< newTo.filename() <<"]" << endl;
			CopyFiles( newFrom, newTo );
		}
		else if( bf::is_regular( newFrom ) )
		{
			AppendSpace();
			cout<<"Copy File ["<< newFrom.filename() <<"] to ["<< newTo.filename() << "]" << endl;
			bf::copy_file( newFrom, newTo, bf::copy_option::overwrite_if_exists );
		}
	}

	--g_iHierarchy;
}


int main()
{
	CopyFiles( "c:\\test", "c:\\test2" );

	system("pause");

	return 0;
}